/*AzsXRMW2y4YbZvrlKvXboyq81pNHo6e9RDQb+JljEDEx0gRS4K3p5d2W07lT3mzT*/
import React, { Component } from 'react';
import constant from '../../constants';
import { stepOneAreaAfterEvent } from './../components/event';
import ampub from 'ampub';
import { base } from 'nc-lightapp-front';

const { NCRadio } = base;
const { utils } = ampub;
const { multiLangUtils, getThemeUtils } = utils;
const { getMultiLangByID } = multiLangUtils;
export default class StepOne extends Component {

    constructor(props) {
        super(props);
        this.state = { inv_type: props.invType }; // 1是快速盘点，2是精细盘点
    }

    componentDidMount() {
        const { form } = this.props;
        // search.setDisabled(constant.AREA.STEP.INVENTORY_RANGE, false);
        form.setFormStatus(constant.AREA.STEP.INVENTORY_DATE, 'edit');
    }

    reSetRangeData = (rangeAreaData) => {
        if (rangeAreaData) {
            this.props.search.setSearchValue(constant.AREA.STEP.INVENTORY_RANGE, rangeAreaData.conditions);
        }
    };

    handleChange = (value) => {
        this.setState({ inv_type: value });
        this.props.isQuickChanged(value);
    };

    render() {
        const { form, search, rangeAreaData } = this.props;
        const { createForm } = form;
        const { NCCreateSearch } = search;
        return (
            <div className={`container-area nc-theme-area-bgc ${`${getThemeUtils()}theme`}`}>
                <div className="area-content">
                    <p>{getMultiLangByID('201203004A-000013') /* 盘点范围*/}</p>
                    {NCCreateSearch(constant.AREA.STEP.INVENTORY_RANGE, {
                        onAfterEvent: stepOneAreaAfterEvent.bind(this),
                        showSearchBtn: false,
                        renderCompleteEvent: this.reSetRangeData.bind(this, rangeAreaData)
                    })}
                </div>
                <div className="area-content">
                    <p>{getMultiLangByID('201203004A-000010') /* 盘点时间*/}</p>
                    {createForm(constant.AREA.STEP.INVENTORY_DATE, {})}
                </div>
                <div className="area-content">
                    <p>{getMultiLangByID('201203004A-000064') /* 盘点类型*/}</p>
                    <NCRadio.NCRadioGroup
                        name={getMultiLangByID('201203004A-000064')}
                        selectedValue={this.state.inv_type}
                        onChange={this.handleChange.bind(this)}
                    >
                        <NCRadio value="1">{getMultiLangByID('201203004A-000065') /* 快速盘点*/}</NCRadio>
                        <NCRadio value="2">{getMultiLangByID('201203004A-000066') /* 精细盘点*/}</NCRadio>
                    </NCRadio.NCRadioGroup>
                </div>
            </div>
        );
    }

}

/*AzsXRMW2y4YbZvrlKvXboyq81pNHo6e9RDQb+JljEDEx0gRS4K3p5d2W07lT3mzT*/